package cn.promonkey.core.toolkit;

import cn.promonkey.core.dto.UserDto;

/** @author 郭晓宇 */
public abstract class UserInfoUtils {

    private static ThreadLocal<UserDto> userThreadLocal = new ThreadLocal<>();

    /**
     * @MethodNmae: getUserInfo
     * @Description: 获取当前登录用户的用户信息
     * @Param: []
     * @return: cn.promonkey.api.manager.dto.UserDto
     */
    public static UserDto getUserInfo() {
        UserDto userDto = userThreadLocal.get();
        return  userDto;
    }

    /**
     * @MethodNmae: setUserInfo
     * @Description: 存储当前登录用户信息
     * @Param: [userDto]
     * @return: void
     */
    public static void setUserInfo(UserDto userDto) {
        userThreadLocal.set(userDto);
    }

    /**
     * @MethodNmae: removeUserInfo
     * @Description: 清除线程变量
     * @Param: []
     * @return: void
     */
    public static void removeUserInfo() {
        userThreadLocal.remove();
    }

}
